* Split an internet media type into its two components; if not
* a two-part name, set the minor type to 'unknown'.
*
- * @param $mime "text/html" etc
+ * @param string $mime "text/html" etc
* @return array ("text", "html") etc
*/
- static function splitMime( $mime ) {
+ public static function splitMime( $mime ) {
if( strpos( $mime, '/' ) !== false ) {
return explode( '/', $mime, 2 );
} else {
Xml::closeElement( 'form' )
);
- list( $this->major, $this->minor ) = self::parseMIME( $mime );
- if ( $this->major == '' || $this->minor == '' || !self::isValidType( $this->major ) ) {
+ list( $this->major, $this->minor ) = File::splitMime( $mime );
+ if ( $this->major == '' || $this->minor == '' || $this->minor == 'unknown' ||
+ !self::isValidType( $this->major ) ) {
return;
}
parent::execute( $par );
return "($download) $plink . . $dimensions . . $bytes . . $user . . $time";
}
-
- protected static function parseMIME( $str ) {
- // searched for an invalid MIME type.
- if( strpos( $str, '/' ) === false ) {
- return array( '', '' );
- }
- list( $major, $minor ) = explode( '/', $str, 2 );
-
- return array(
- ltrim( $major, ' ' ),
- rtrim( $minor, ' ' )
- );
- }
-
protected static function isValidType( $type ) {
// From maintenance/tables.sql => img_major_mime
$types = array(